// yaoxiangqin.js
import api from "../../../utils/api"
import util from "../../../utils/util"
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    uType: app.globalData.userType,
    userType:"",
    showColorBird:true,
    showSubmenu: false,
    users:[],
    // userType:"",
    tags: [{
      tagValue: "气质",
      selected: false
    }, {
      tagValue: "高冷",
      selected: false
    }, {
      tagValue: "开朗",
      selected: false
    }, {
      tagValue: "知性",
      selected: false
    }, {
      tagValue: "御姐",
      selected: false
    }, {
      tagValue: "安静",
      selected: false
    }, {
      tagValue: "85后",
      selected: false
    }, {
      tagValue: "90后",
      selected: false
    }, {
      tagValue: "乖巧",
      selected: false
    }, {
      tagValue: "慢热型",
      selected: false
    }, {
      tagValue: "主动型",
      selected: false
    }],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);
    var that = this;
    this.setData({
      uType: options.type,
      userType:app.globalData.userType
    });
    if (options.type && options.type == "user"){
        //牵手的人
      wx.request({
        url: api.saveUserList,
        data: {
          id:app.globalData.openid
        },
        success: function (response) {
          console.log(response.data.data);
          that.setData({
            users: response.data.data
          });
        },
        header: {
          "content-type": "application/x-www-form-urlencoded"
        },
        method: "POST"
      })

    }else{
        // 我要相亲
      wx.request({
        url: api.getUserInfos,
        data: {},
        success: function (response) {
          console.log(response.data.data);
          that.setData({
            users: response.data.data
          });
        },
        header: {
          "content-type": "application/x-www-form-urlencoded"
        },
        method: "POST"
      })
    }
    util.isLogin();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
  /**
 * 显示菜单
 */
  showSubmenu: function () {
    this.setData({
      showSubmenu: !this.data.showSubmenu
    });
  },
  selectTag: function (options) {
    console.log('选择标签');
    debugger;
    console.log();
    this.data.tags[options.currentTarget.dataset.index].selected = !this.data.tags[options.currentTarget.dataset.index].selected;
    this.setData({
      tags:this.data.tags 
    });

  },
  /**
   * 加载图片
   */
  loadHeadImage:function(e){
    console.log("加载图片成功！");
    var that = this;
    console.log(e);
   
    setTimeout(function(){
      that.setData({
        showColorBird: false
      });
    },4000);
    
  },
  qianshou:function(e){
    console.log("要牵手");
    console.log(e.target.dataset.id);
  }
})